using System.ComponentModel.DataAnnotations.Schema;
using System.Data.Entity.ModelConfiguration;

namespace WebDauGia.Domain.Models.Mapping
{
    public class DonNhapHangMap : EntityTypeConfiguration<DonNhapHang>
    {
        public DonNhapHangMap()
        {
            // Primary Key
            this.HasKey(t => t.id);

            // Properties
            this.Property(t => t.trangthai)
                .IsFixedLength()
                .HasMaxLength(10);

            // Table & Column Mappings
            this.ToTable("DonNhapHang");
            this.Property(t => t.id).HasColumnName("id");
            this.Property(t => t.idnhanvien).HasColumnName("idnhanvien");
            this.Property(t => t.idnguoiban).HasColumnName("idnguoiban");
            this.Property(t => t.tongtien).HasColumnName("tongtien");
            this.Property(t => t.ngay).HasColumnName("ngay");
            this.Property(t => t.trangthai).HasColumnName("trangthai");

            // Relationships
            this.HasOptional(t => t.KhachHang)
                .WithMany(t => t.DonNhapHangs)
                .HasForeignKey(d => d.idnguoiban);
            this.HasOptional(t => t.NhanVien)
                .WithMany(t => t.DonNhapHangs)
                .HasForeignKey(d => d.idnhanvien);

        }
    }
}
